#include <REGX52.H>
#include "Delay.h"
#include "Timer0.h"

unsigned char compare,counter;
unsigned int i;
void main()
{
    Timer0_Init();
	while(1)
	{
        for(i=0;i<100;i++)
        {
            compare++;
            Delay(10);
        }
        for(i=0;i<100;i++)
        {
            compare--;
            Delay(10);

        }

	}
}

void Timer0_Routine() interrupt 1
{
	TL0 = 0x9C;				//设置定时初始值
	TH0 = 0xFF;				//设置定时初始值
    counter++;
    counter%=100;
    if(counter<compare)
    {
        P2_0=0;
    }
    else{P2_0=1;}
}
